﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Imaginecup.stage;
using Imaginecup.gameState.malaria.manager;
using imaginecup.objectManager;
using Imaginecup.gameState.malaria.component.etc;
using Imaginecup.util.collision;
using imaginecup.util;
using Imaginecup.util;
using imaginecup.information;
using Imaginecup.stateManager;
using Imaginecup.factory;
using Imaginecup.gameState.menu;

namespace Imaginecup.gameState.malaria.stage
{
    public abstract class MalariaBaseStage : BaseStage
    {
        protected ChildGenerator m_ChildGenerator;
        protected MalariaGenerator m_MalariaGenerator;


        private CmpMenuIcon m_MenuIcon;

        protected void SetMenuIcon(ObjectManager objMan)
        {
            m_MenuIcon = new CmpMenuIcon(new GObjectID(), objMan);
            objMan.AddComponent(m_MenuIcon);


        }


        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {

            IMouseInputHandler mouseInput = MouseInputHandler.GetInputHandler();

            if (mouseInput.IsOneClickUp() && Collision.CollisionByPoint((EntityInfo)m_MenuIcon.GetEntityInfo(),
                mouseInput.Position))
            {
                GameStateManager stateMan = shareData.StateShareData.GetShareData().GetGameStateMan();

                IFactory factory = StateFactory.GetStateFactory();

                IGameState menuState = (IGameState)factory.GetObject(StateFactoryID.State_Menu);
                IMenuController menuControl = (IMenuController)menuState;

                menuControl.SetChooseControl((IChooseControl)m_MalariaStageMan);
                menuControl.SetResetController((IResetController)m_MalariaStageMan);

                stateMan.PushState(menuState);

                return;
            }

            m_ChildGenerator.Update(gameTime);
            m_MalariaGenerator.Update(gameTime);
            base.Update(gameTime);
        }

        public override void Release()
        {
            m_MenuIcon.Release();
            base.Release();
        }
    }
}
